package cn.hesion.Partition;
/**
 * ClassName: CustomPatitioner <br/>
 * Description: <br/>
 * date: 2021/2/3 10:27<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @program: ClientDemo
 * @description: 自定义分区器
 * @author: hesion
 * @create: 2021-02-03 10:27
 **/
public class CustomPatitioner extends Partitioner<Text,PartitionBean> {
    @Override
    public int getPartition(Text text, PartitionBean partitionBean, int numPartitions) {
        int partition=0;
        final  String appkey = text.toString();
        if(appkey.equals("kar")){
            partition=1;
        }else if(appkey.equals("pandora")){
            partition=2;
        }else {
            partition=0;
        }
        return partition;
    }
}
